﻿using System;
using System.Web.UI.WebControls;

namespace Altairis.Web.UI.WebControls {

    public class DateTimeValidator : BaseValidator {

        protected override bool EvaluateIsValid() {
            // Get string to validate
            string s = this.GetControlValidationValue(this.ControlToValidate);

            // Always respond to empty string as valid
            if (string.IsNullOrEmpty(s)) return true;

            // Try to parse string as datetime
            DateTime empty;
            return DateTime.TryParse(s, out empty);
        }
    }
}